#!/usr/bin/env node


const inquirer = require('inquirer')
const fs = require('fs')
const path = require('path')
const ejs = require('ejs')

inquirer.prompt([
    {
        type: "input",
        name: "name",
        message: "You project name",
        default: 'czg-task01'
    },
    {
        tpe:"input",
        name:"version",
        message:"project version",
        default:'0.0.1'
    }
])
    .then(anwsers => {

        
        const temDir = path.join(__dirname, 'templates')

        const destDir = process.cwd()
        
        fs.readdir(temDir,(err,files) =>{
            if(err) throw err
            files.forEach(file=>{
                ejs.renderFile(path.join(temDir,file),anwsers,(err,res)=>{
                    if(err) throw err
                    fs.writeFileSync(path.join(destDir,file),res)
                })
            })
        })
    })